package com.itheima.blog.admin.controller;


import com.itheima.blog.admin.service.ITBlogService;
import com.itheima.common.domain.BlogPageQuery;
import com.itheima.common.domain.PageResDto;
import com.itheima.common.domain.R;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 博客文章表 前端控制器
 * </p>
 *
 * @author chx
 * @since 2023-07-11
 */
@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
public class TBlogController {
    private final ITBlogService blogService;

    @GetMapping("/blog/page")
    @ApiOperation("博客管理-分页搜索")
    public PageResDto pageQuery( BlogPageQuery pageQuery){
        PageResDto pageResDto = blogService.pageQueryBlog(pageQuery);
        if (pageResDto!=null){
            pageResDto.setCode(200);
            pageResDto.setMsg("查询成功");
        }
        return pageResDto;
    }

    @DeleteMapping("/blog")
    @ApiOperation("博客管理-删除")
    public R deleteBlog(@RequestParam("blogId")Integer blogId){
        blogService.deleteBlog(blogId);
        return R.ok();
    }
}
